package com.yn.pet.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum OtherAlarmTypeEnum {
    // 震动报警，code 对应 1
    VIBRATION_ALARM(1, "震动报警"),
    // 低电量报警，code 对应 2
    LOW_POWER_ALARM(2, "低电量报警"),
    // 离线报警，code 对应 3
    OFFLINE_ALARM(3, "离线报警");

    private Integer code;
    private String name;

    public static OtherAlarmTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (OtherAlarmTypeEnum alarmType : OtherAlarmTypeEnum.values()) {
            if (alarmType.getCode().equals(code)) {
                return alarmType;
            }
        }
        return null;
    }
}